<?php

namespace app\admin\model;

use think\Model;


class ReturnCash extends Model
{

    

    // 表名
    protected $table = 'return_cash';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'pay_style_text',
        'is_over_text'
    ];
    

    
    public function getPayStyleList()
    {
        return ['1' => __('Pay_style 1'), '2' => __('Pay_style 2'), '3' => __('Pay_style 3')];
    }

    public function getIsOverList()
    {
        return ['0' => __('Is_over 0'), '1' => __('Is_over 1'), '2' => __('Is_over 2')];
    }


    public function getPayStyleTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_style']) ? $data['pay_style'] : '');
        $list = $this->getPayStyleList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsOverTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_over']) ? $data['is_over'] : '');
        $list = $this->getIsOverList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function users()
    {
        return $this->belongsTo('Users', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function payment()
    {
        return $this->belongsTo('Payment', 'payment_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
